package model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;

/**
 * @author soreas + morarg Entity implementation class for Entity: Resource
 * 
 */
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorValue("Resource")
// @SequenceGenerator(name="seq", initialValue=1, allocationSize=100)
public class Resource extends Folder implements Serializable {

	@Column(nullable = false)
	private String content;

	private User lockUser;
	private static final long serialVersionUID = 1L;

	public Resource() {
		super();
	}

	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public User getLockUser() {
		return this.lockUser;
	}

	public void setLockUser(User lockUser) {
		this.lockUser = lockUser;
	}

	@Override
	public String toString() {
		return "Resource [content=" + content + ", lockUser=" + lockUser + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((content == null) ? 0 : content.hashCode());
		result = prime * result
				+ ((lockUser == null) ? 0 : lockUser.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Resource other = (Resource) obj;
		if (content == null) {
			if (other.content != null)
				return false;
		} else if (!content.equals(other.content))
			return false;
		if (lockUser == null) {
			if (other.lockUser != null)
				return false;
		} else if (!lockUser.equals(other.lockUser))
			return false;
		return true;
	}

}
